/* JavaScript client component for Facebook OAuth */

/* facebook html5 like button init code */
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1&appId=138524109534751";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

/* attach the login functionality */
$("#knFacebookLoginButton").click(function(){
	facebookOAuthLogin();
});
/* and the logout methods also */
$("#knFacebookLogoutButton").click(function(){
	location.href = "/index.php?logout";
});

/* login with facebook using OAuth */
function facebookOAuthLogin(){
	var oAuthUrl = "https://www.facebook.com/dialog/oauth?"
		+ "client_id=138524109534751&redirect_uri="
		+ facebook_redirect_url + "&scope=user_about_me";
	
	_gaq.push(['_trackEvent', 'Authentication', 
	           'InitiateLogin', 'Facebook']);
	
	location.href=oAuthUrl;	
}